package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author jiyonghui
 * @className LaunchChannelTypeEnum
 * @description
 * @date 2020/1/6   14:41
 */
@Getter
public enum LaunchChannelTypeEnum {

    /**
     * 复制指令投放
     */
    COPY_INSTRUCTION_DELIVERY(0, "enum.launchChannelType.name.copy_instruction_delivery", "copyInstructionDelivery"),
    COUPON_BAG(1, "enum.launchChannelType.name.coupon_bag", "couponBag"),
    ORDER_COMPLETION_PAGE(2, "enum.launchChannelType.name.order_completion_page", "orderCompletionPage"),
    ;

    private Integer code;
    private String name;
    private String attr;

    LaunchChannelTypeEnum(Integer code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }


    public static LaunchChannelTypeEnum getByCode(Integer number) {
        for (LaunchChannelTypeEnum value : values()) {
            if (Objects.equals(value.getCode(), number)) {
                return value;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
